package com.lvy.hczn.front.business.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lvy.hczn.front.business.common.CacheConstants;
import com.lvy.hczn.front.common.core.redis.RedisCache;
import com.lvy.hczn.front.system.domain.business.ConvertData;
import com.lvy.hczn.front.business.mapper.ConvertDataMapper;
import com.lvy.hczn.front.business.service.ConvertDataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class ConvertDataServiceImpl extends ServiceImpl<ConvertDataMapper, ConvertData> implements ConvertDataService {

    @Autowired
    private ConvertDataMapper convertDataMapper;

    @Autowired
    private RedisCache redisCache;

    /**
     * 代码转换，存到redis
     *
     * @return
     * @author yw
     * @date 2023-10-22 15:23:56
     */
    @Override
    public List<ConvertData> converttList() {
        List<ConvertData> list = super.list();
        list.forEach(item -> {
            redisCache.set(CacheConstants.CONVERT_CODE + item.getAnswerId() + ":" + item.getErrorId(), item.getMsg());
        });
        return list;
    }
}
